package docoffice.gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import docoffice.doss.Patient;

public class EditUser extends JPanel {
	
	private JLabel title, blank, search, blank2;
	
	private JTextField searchField;
	
	private JButton searchButton;
	
	public EditUser() {
		title = new JLabel("Edit/Delete a User");
		blank = new JLabel();
		blank2 = new JLabel();
		search = new JLabel("Enter user's name");
		
		searchField = new JTextField(25);
		searchField.addActionListener(new FieldListener());
		
		searchButton = new JButton("Search");
		searchButton.addActionListener(new ButtonListener());
		
		setLayout(new GridLayout(3, 2, 15, 10));
		add(title);
		add(blank);
		add(search);
		add(searchField);
		add(blank2);
		add(searchButton);
		
		setPreferredSize(new Dimension(400, 125));
		setBackground(Color.WHITE);
	}
	
	private class FieldListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			String searchInput = searchField.getText();
		}
	}
	
	private class ButtonListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			String searchInput = searchField.getText();
			System.out.println("Searching for patient: " + searchInput);
			Patient p = new Patient(searchInput);
			p = p.lookupPatient(searchInput);
			System.out.println("Name: " + p.getName() + " Address: " + p.getAddress() + " Age: " + p.getAge());
		}
	}
}
